home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / tos / progut~1 / stdwin.zoo / h / tools.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-03-30  |  3.2 KB  |  165 lines

  1. /* Useful definitions, include files etc. */
  2.  
  3. #include "configure.h"
  4.  
  5. /* C library stuff: */
  6.  
  7. #include <stdio.h> /* Must be before stdwin.h because it defines NULL */
  8. #include <ctype.h>
  9.  
  10. #ifdef __GNUC__        /* all protos */
  11. #  ifdef atarist
  12. #    include <stddef.h>
  13. #    include <stdlib.h>
  14. #    include <string.h>
  15. #    include <memory.h>
  16. #    include <unixlib.h>
  17. #  endif
  18. #endif
  19.  
  20. #ifdef __STDC__
  21. #include <string.h>
  22. #else
  23. #ifdef SYSV
  24.  
  25. #include <string.h>
  26. #define index strchr
  27. #define rindex strrchr
  28.  
  29. #else
  30.  
  31. #include <strings.h>
  32. #ifdef LSC
  33. #define index strchr
  34. #define rindex strrchr
  35. #else
  36. #define strchr index
  37. #define strrchr rindex
  38. #endif
  39.  
  40. #endif
  41. #endif
  42.  
  43. #ifndef _SIZE_T
  44. #define size_t    unsigned int /* or whatever is appro */
  45. #define _SIZE_T
  46. #endif
  47.  
  48. #ifdef __STDC__
  49. void *malloc(size_t), *calloc(size_t, size_t), *realloc(void *, size_t);
  50. void free(void *);
  51. #else
  52. #ifdef THINK_C
  53. void *malloc(), *calloc(), *realloc();
  54. #else
  55. char *malloc(), *calloc(), *realloc();
  56. #endif
  57. int free();
  58. #endif
  59.  
  60.  
  61. char *ctime();
  62. #ifndef LSC
  63. long time();
  64. #endif
  65.  
  66. char *getenv();
  67.  
  68. extern int errno;
  69.  
  70. #ifdef NO_MEMCPY
  71. #define memcpy(dest, src, n)    bcopy(src, dest, n)
  72. #define memcmp(a, b, cnt)    bcmp(a, b, cnt)
  73. #else
  74. #ifdef __STDC__
  75. void *  memcpy(void * dst, const void * src, size_t size);
  76. #else
  77. char *memcpy();
  78. int memcmp(const void *, const void *, size_t);
  79. #endif
  80. #endif
  81.  
  82. /* For getopt: */
  83. extern int optind;
  84. extern char * optarg;
  85.  
  86. /* Dynamic array macros: */
  87. #include "l_defs.h"
  88.  
  89. /* Boolean data type: */
  90. #ifndef bool
  91. #define bool int
  92. #endif
  93. #define tbool char    /* Tiny bool, used in structs or arrays */
  94. #define FALSE 0
  95. #define TRUE 1
  96.  
  97. /* Character shorthands: */
  98. #define EOS '\0'
  99. #define EOL '\n'
  100.  
  101. /* Copy string to malloc'ed memory: */
  102. char *strdup();
  103. char *strndup();
  104.  
  105. /* Other useful macros: */
  106.  
  107. #define CNTRL(x) ((x) & 0x1f) /* Usage: CNTRL('X') */
  108.  
  109. #define ABS(x) ((x) < 0 ? -(x) : (x))
  110.  
  111. #ifndef MIN
  112. #define MIN(a, b) ((a) < (b) ? (a) : (b))
  113. #endif
  114. #ifndef MAX
  115. #define MAX(a, b) ((a) > (b) ? (a) : (b))
  116. #endif
  117.  
  118. #define CLIPMIN(var, min) if ((var) >= (min)) ; else (var)= (min)
  119. #define CLIPMAX(var, max) if ((var) <= (max)) ; else (var)= (max)
  120.  
  121. /* Memory allocation macros: */
  122.  
  123. #define ALLOC(type) ((type*) malloc((size_t)sizeof(type)))
  124.  
  125. /* Array (re)allocation macros.
  126.    RESIZE yields nonzero if the realloc succeeded. */
  127.  
  128. #define NALLOC(type, n) ((type*) malloc((size_t)((n) * sizeof(type))))
  129. #ifdef __STDC__
  130. #define FREE(p) ((p) ? free((void*)(p)) : 0, (p)= 0)
  131. #define RESIZE(var, type, n) \
  132.     (var= (type *) realloc((void*)var, (size_t)((n) * sizeof(type))))
  133. #else
  134. #define FREE(p) ((p) ? free((char*)(p)) : 0, (p)= 0)
  135. #define RESIZE(var, type, n) \
  136.     (var= (type *) realloc((char*)var, (size_t)((n) * sizeof(type))))
  137. #endif
  138.  
  139. #ifdef __STDC__
  140. # define    P(s) s
  141. #else
  142. # define P(s) ()
  143. #endif
  144.  
  145. /* endian.c */
  146. void endianism P((void ));
  147.  
  148. /* glob.c */
  149. int glob P((char *pat , char *buf , unsigned int size ));
  150.  
  151. /* monocase.c */
  152. int monocasecmp P((char *a , char *b ));
  153.  
  154. /* strdup.c */
  155. char *strdup P((const char *str ));
  156. char *strndup P((char *str , int len ));
  157.  
  158. /* swap.c */
  159. void shortswap P((short *data , int len ));
  160. void longswap P((long *data , int len ));
  161. void swpscpy P((short *dst , short *src , int nshorts ));
  162. void swplcpy P((long *dst , long *src , int nlongs ));
  163.  
  164. #undef P
  165.